
<!DOCTYPE HTML>
<html lang="Chinese" >
    <head>
        <title>编码规则和风格 · freeRTOS中文文档</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.0">
        <meta name="author" content="tangguocheng">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prismx/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="许可.html" />
    
    
    <link rel="prev" href="freeRTOS介绍.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.xn--4gqa63c686ta68iba.ren/" target="_blank" class="custom-link">博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    关于
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="freeRTOS介绍.html">
            
                <a href="freeRTOS介绍.html">
            
                    
                    简介
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.2.1" data-path="编码规则和风格.html">
            
                <a href="编码规则和风格.html">
            
                    
                    编码规则和风格
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="许可.html">
            
                <a href="许可.html">
            
                    
                    许可
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="快速开始指南.html">
            
                <a href="快速开始指南.html">
            
                    
                    快速开始指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../入门/readme.html">
            
                <a href="../入门/readme.html">
            
                    
                    入门
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../入门/任务和协程/readme.html">
            
                <a href="../入门/任务和协程/readme.html">
            
                    
                    任务和协程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1.1" data-path="../入门/任务和协程/任务.html">
            
                <a href="../入门/任务和协程/任务.html">
            
                    
                    任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.1.2" data-path="../入门/任务和协程/协程.html">
            
                <a href="../入门/任务和协程/协程.html">
            
                    
                    协程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../入门/通信机制/readme.html">
            
                <a href="../入门/通信机制/readme.html">
            
                    
                    通信机制
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.2.1" data-path="../入门/通信机制/队列.html">
            
                <a href="../入门/通信机制/队列.html">
            
                    
                    队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.2" data-path="../入门/通信机制/二值信号量.html">
            
                <a href="../入门/通信机制/二值信号量.html">
            
                    
                    二值信号量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.3" data-path="../入门/通信机制/计数信号量.html">
            
                <a href="../入门/通信机制/计数信号量.html">
            
                    
                    计数信号量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.4" data-path="../入门/通信机制/互斥量.html">
            
                <a href="../入门/通信机制/互斥量.html">
            
                    
                    互斥量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.5" data-path="../入门/通信机制/递归互斥量.html">
            
                <a href="../入门/通信机制/递归互斥量.html">
            
                    
                    递归互斥量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2.6" data-path="../入门/通信机制/任务通知.html">
            
                <a href="../入门/通信机制/任务通知.html">
            
                    
                    任务通知
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../入门/事件组/事件组.html">
            
                <a href="../入门/事件组/事件组.html">
            
                    
                    事件组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../入门/软件定时器/软件定时器.html">
            
                <a href="../入门/软件定时器/软件定时器.html">
            
                    
                    软件定时器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../进阶/readme.md">
            
                <span>
            
                    
                    进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../进阶/源代码组织结构/源代码组织结构.html">
            
                <a href="../进阶/源代码组织结构/源代码组织结构.html">
            
                    
                    源代码组织结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../进阶/高级/配置文件.html">
            
                <a href="../进阶/高级/配置文件.html">
            
                    
                    配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../进阶/高级/跟踪特性.html">
            
                <a href="../进阶/高级/跟踪特性.html">
            
                    
                    跟踪特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../进阶/高级/低功耗支持.html">
            
                <a href="../进阶/高级/低功耗支持.html">
            
                    
                    低功耗支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../进阶/高级/运行时间统计.html">
            
                <a href="../进阶/高级/运行时间统计.html">
            
                    
                    运行时间统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../进阶/高级/队列集合.html">
            
                <a href="../进阶/高级/队列集合.html">
            
                    
                    队列集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../进阶/高级/中断延迟.html">
            
                <a href="../进阶/高级/中断延迟.html">
            
                    
                    中断延迟
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../进阶/高级/静态分配与动态分配.html">
            
                <a href="../进阶/高级/静态分配与动态分配.html">
            
                    
                    静态和动态内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../进阶/高级/内存管理.html">
            
                <a href="../进阶/高级/内存管理.html">
            
                    
                    内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../进阶/高级/栈溢出检测.html">
            
                <a href="../进阶/高级/栈溢出检测.html">
            
                    
                    栈溢出检测
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../进阶/高级/钩子函数.html">
            
                <a href="../进阶/高级/钩子函数.html">
            
                    
                    钩子函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="../进阶/高级/线程本地存储.html">
            
                <a href="../进阶/高级/线程本地存储.html">
            
                    
                    线程本地存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="../进阶/高级/移植指南.html">
            
                <a href="../进阶/高级/移植指南.html">
            
                    
                    移植指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path="../进阶/高级">
            
                <span>
            
                    
                    在windows上模拟
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >编码规则和风格</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
                                <section class="normal markdown-section">
                                
                                <h2 id="codeing-standard">Codeing Standard</h2><p>freeRTOS&#x7684;&#x6E90;&#x4EE3;&#x7801;&#x7B26;&#x5408;<a href="http://www.misra.org.uk/" target="_blank">MISRA</a>&#x7F16;&#x7801;&#x6807;&#x51C6;&#xFF0C;&#x8FD9;&#x4E2A;&#x7F16;&#x7801;&#x6807;&#x51C6;&#x8001;&#x957F;&#x4E86;&#xFF0C;&#x800C;&#x4E14;&#x60F3;&#x8981;&#x5F97;&#x5230;&#x8FD9;&#x73A9;&#x610F;&#x8FD8;&#x6709;&#x5411;MISRA&#x4ED8;&#x4E00;&#x70B9;&#x70B9;&#x5C0F;&#x94B1;&#xFF0C;&#x6240;&#x4EE5;&#x4E0B;&#x9762;&#x53EA;&#x590D;&#x5236;&#x4E86;&#x4E00;&#x5C0F;&#x90E8;&#x5206;&#x3002;</p><p>&#x8131;&#x79BB;MISRA&#x6807;&#x51C6;&#x7684;&#x90E8;&#x5206;&#xFF1A;</p><ul><li>&#x4E24;&#x4E2A;API&#x6709;&#x591A;&#x4F59;&#x4E00;&#x4E2A;&#x51FA;&#x53E3;&#x3002;&#x5728;&#x8FD9;&#x4E24;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x51FA;&#x4E8E;&#x5BF9;&#x4E34;&#x754C;&#x6548;&#x7387;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x540C;&#x6807;&#x51C6;&#x7684;&#x504F;&#x5DEE;&#x662F;&#x5141;&#x8BB8;&#x7684;
</li>
<li>&#x5F53;&#x5728;&#x521B;&#x5EFA;&#x4EFB;&#x52A1;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6E90;&#x4EE3;&#x7801;&#x5728;&#x4E3A;&#x4EFB;&#x52A1;&#x521B;&#x5EFA;&#x5806;&#x6808;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x9700;&#x8981;&#x64CD;&#x4F5C;&#x5185;&#x5B58;&#x53BB;&#x5B9A;&#x4F4D;&#x8D77;&#x59CB;&#x4E0E;&#x7ED3;&#x675F;&#x5730;&#x5740;&#xFF0C;&#x56E0;&#x4E3A;&#x6E90;&#x4EE3;&#x7801;&#x9700;&#x8981;&#x5728;&#x6240;&#x6709;&#x652F;&#x6301;&#x7684;&#x67B6;&#x6784;&#x4E0A;&#x5DE5;&#x4F5C;&#xFF0C;&#x8FD9;&#x4E9B;&#x67B6;&#x6784;&#x6709;8&#x3001;16&#x3001;24&#x3001;32-&#x3002;&#x5F53;&#x8FD9;&#x4E9B;&#x6307;&#x9488;&#x8FD0;&#x7B97;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;&#x8FD0;&#x7B97;&#x7ED3;&#x679C;&#x7531;&#x6E90;&#x4EE3;&#x7801;&#x7F16;&#x7A0B;&#x68C0;&#x67E5;&#x6B63;&#x786E;&#x6027;
</li>
<li>&#x8FFD;&#x8E2A;&#x5B8F;&#x5728;&#x9ED8;&#x8BA4;&#x4E0B;&#x662F;&#x7A7A;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x8981;&#x751F;&#x6210;&#x4EFB;&#x4F55;&#x4EE3;&#x7801;&#x3002;&#x56E0;&#x6B64;&#xFF0C;MISRA&#x7B26;&#x5408;&#x6027;&#x68C0;&#x67E5;&#x5728;&#x865A;&#x62DF;&#x5B8F;&#x5B9A;&#x4E49;&#x4E0B;&#x8FDB;&#x884C;
</li></ul>
<p>freeRTOS&#x6784;&#x5EFA;&#x4E8E;&#x591A;&#x79CD;&#x4E0D;&#x540C;&#x7684;&#x7F16;&#x8BD1;&#x5668;&#xFF0C;&#x5176;&#x4E2D;&#x7684;&#x4E00;&#x4E9B;&#x6BD4;&#x5176;&#x4ED6;&#x7684;&#x5148;&#x8FDB;&#x3002;&#x56E0;&#x6B64;&#xFF0C;freeRTOS&#x4E0D;&#x4F7F;&#x7528;&#x4EFB;&#x4F55;&#x5DF2;&#x7ECF;&#x6216;&#x81EA;C99&#x6807;&#x51C6;&#x5F15;&#x5165;&#x5230;C&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x529F;&#x80FD;&#x6216;&#x8BED;&#x6CD5;&#x3002;&#x5728;&#x4F7F;&#x7528;<code>stdin.h</code>&#x8FD9;&#x4E2A;&#x5934;&#x6587;&#x4EF6;&#x65F6;&#x662F;&#x4E2A;&#x4F8B;&#x5916;&#xFF0C;&#x5728;<code>FreeRTOS/Source/include</code>&#x8DEF;&#x5F84;&#x4E0B;&#x7531;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x540D;&#x4E3A;<code>stdint.readme</code>&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x91CD;&#x547D;&#x540D;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x4E3A;<code>stdin.h</code>&#xFF0C;&#x4EE5;&#x63D0;&#x4F9B;&#x5FC5;&#x8981;&#x7684;&#x7F16;&#x8BD1;FreeRTOS&#x7684;<code>stdint</code>&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#xFF0C;&#x524D;&#x63D0;&#x662F;&#x8981;&#x4F60;&#x7684;&#x7F16;&#x8BD1;&#x5668;&#x4E0D;&#x63D0;&#x4F9B;&#x81EA;&#x5DF1;&#x7684;&#x3002;</p><h2 id="&#x547D;&#x540D;&#x7EA6;&#x5B9A;">&#x547D;&#x540D;&#x7EA6;&#x5B9A;</h2><p>RTOS&#x5185;&#x6838;&#x4E0E;&#x5B9E;&#x4F8B;&#x4EE3;&#x7801;&#x9075;&#x5FAA;&#x5982;&#x4E0B;&#x7EA6;&#x5B9A;&#xFF1A;</p><h3 id="&#x53D8;&#x91CF;">&#x53D8;&#x91CF;</h3><ul><li><code>uint32_t</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x547D;&#x540D;&#x524D;&#x7F00;<code>ul</code>&#xFF0C;<code>u</code>&#x4EE3;&#x8868;<code>usigned</code>(&#x4E0B;&#x540C;)&#xFF0C;<code>l</code>&#x4EE3;&#x8868;<code>long</code>&#x3002;
</li>
<li><code>uint16_t</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x547D;&#x540D;&#x524D;&#x7F00;<code>us</code>&#xFF0C;<code>s</code>&#x4EE3;&#x8868;<code>short</code>&#x3002;
</li>
<li><code>uint8_t</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x547D;&#x540D;&#x524D;&#x7F00;<code>uc</code>&#xFF0C;<code>c</code>&#x4EE3;&#x8868;<code>char</code>&#x3002;
</li>
<li>&#x5BF9;&#x4E8E;&#x975E;<code>stdint</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x524D;&#x7F00;&#x4E3A;<code>x</code>&#xFF0C;&#x6BD4;&#x5982;<code>BaseType_t</code>&#x548C;<code>TickType_t</code>,&#x5206;&#x522B;&#x662F;&#x7528;&#x4E8E;&#x4E3A;&#x4E0D;&#x540C;&#x67B6;&#x6784;&#x5B9A;&#x4E49;&#x7684;&#x57FA;&#x7840;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x4EE5;&#x65B9;&#x4FBF;&#x79FB;&#x690D;&#xFF0C;&#x548C;&#x7528;&#x4E8E;&#x4FDD;&#x5B58;RTOS tick&#x8BA1;&#x6570;&#x503C;&#x7684;&#x53D8;&#x91CF;&#x7C7B;&#x578B;&#x3002;&#x540C;&#x7406;&#xFF0C;&#x5BF9;&#x4E8E;&#x65E0;&#x7B26;&#x53F7;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x4F8B;&#x5982;<code>UBaseType_t</code>&#x524D;&#x7F00;&#x4E3A;<code>ux</code>&#x3002;
</li>
<li><code>size_t</code>&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x547D;&#x540D;&#x524D;&#x7F00;<code>x</code>
</li>
<li>&#x679A;&#x4E3E;&#x7C7B;&#x578B;&#x53D8;&#x91CF;&#x524D;&#x7F00;&#x4E3A;<code>e</code>
</li>
<li>&#x5BF9;&#x4E8E;&#x6307;&#x9488;&#x62E5;&#x6709;&#x800C;&#x5916;&#x7684;&#x524D;&#x7F00;<code>p</code>,&#x4F8B;&#x5982;&#x4E00;&#x4E2A;<code>uint16_t</code>&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;&#x53D8;&#x91CF;&#xFF0C;&#x524D;&#x7F00;&#x4E3A;<code>pus</code>
</li>
<li>&#x4E0E;MISRA&#x6807;&#x51C6;&#x4E00;&#x81F4;&#xFF0C;<code>char</code>&#x578B;&#x53D8;&#x91CF;&#x53EA;&#x5141;&#x8BB8;&#x7528;&#x4E8E;ASCII&#x7801;&#xFF0C;&#x5E76;&#x4E14;&#x524D;&#x7F00;&#x4E3A;<code>c</code>
</li>
<li>&#x540C;&#x7406;<code>char *</code>&#x6307;&#x9488;&#x53EA;&#x5141;&#x8BB8;&#x6307;&#x5411;ASCII&#x7801;&#x5B57;&#x7B26;&#xFF0C;&#x524D;&#x7F00;&#x4E3A;<code>pc</code>
</li></ul>
<h3 id="&#x51FD;&#x6570;">&#x51FD;&#x6570;</h3><ul><li>&#x6587;&#x4EF6;&#x8303;&#x56F4;&#x7684;&#x9759;&#x6001;&#x51FD;&#x6570;(<code>static</code>&#x9650;&#x5B9A;)&#x524D;&#x7F00;<code>prv</code>
</li>
<li>API&#x51FD;&#x6570;&#x7684;&#x524D;&#x7F00;&#x7531;&#x5B83;&#x4EEC;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x51B3;&#x5B9A;&#xFF0C;&#x5177;&#x4F53;&#x53C2;&#x7167;&#x53D8;&#x91CF;&#x7684;&#x547D;&#x540D;&#x7EA6;&#x5B9A;&#x3002;&#x540C;&#x65F6;&#xFF0C;&#x5BF9;&#x4E8E;<code>void</code>&#x524D;&#x7F00;&#x4E3A;<code><span class="token function">v</span></code>
</li>
<li>API&#x51FD;&#x6570;&#x7684;&#x540D;&#x5B57;&#x9664;&#x6839;&#x636E;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x786E;&#x5B9A;&#x7684;&#x524D;&#x7F00;&#x5916;&#xFF0C;&#x540D;&#x79F0;&#x7531;&#x5176;&#x6240;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x540D;&#x4F5C;&#x4E3A;&#x5F00;&#x59CB;&#x3002;&#x4F8B;&#x5982;<code>vTaskDelete</code>&#xFF0C;&#x4EE3;&#x8868;&#x5176;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x4E3A;<code>void</code>&#xFF0C;&#x8FD9;&#x4E2A;API&#x51FD;&#x6570;&#x4FDD;&#x5B58;&#x5728;<code>task.c</code>&#x6587;&#x4EF6;&#x4E2D;
</li></ul>
<h3 id="&#x5B8F;">&#x5B8F;</h3><ul><li>&#x540C;API&#x51FD;&#x6570;&#x7C7B;&#x4F3C;&#xFF0C;&#x5B8F;&#x7684;&#x5F00;&#x5934;&#x662F;&#x5B9A;&#x4E49;&#x5B83;&#x7684;&#x6587;&#x4EF6;&#x540D;&#xFF0C;&#x524D;&#x7F00;&#x7EDF;&#x4E00;&#x4F7F;&#x7528;&#x5C0F;&#x5199;&#x3002;&#x6BD4;&#x5982;&#xFF0C;<code>configUSE_PREEMPTION</code>&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5B9A;&#x4E49;&#x4E8E;<code>freeRTOSConfig.h</code>&#x6587;&#x4EF6;&#x7684;&#x5B8F;
</li>
<li>&#x9664;&#x4E86;&#x524D;&#x7F00;&#xFF0C;&#x5B8F;&#x7684;&#x5176;&#x4ED6;&#x90E8;&#x5206;&#x7EDF;&#x4E00;&#x4F7F;&#x7528;&#x5927;&#x5199;&#xFF0C;&#x5E76;&#x4E14;&#x6BCF;&#x4E2A;&#x5355;&#x8BCD;&#x4E4B;&#x95F4;&#x7531;&#x4E0B;&#x5212;&#x7EBF;&#x5206;&#x9694;
</li></ul>
<h3 id="&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x6570;&#x636E;&#x7C7B;&#x578B;</h3><p>&#x4EC5;<code>stdint.h</code>&#x4E2D;&#x7684;&#x7C7B;&#x578B;&#x548C;RTOS&#x81EA;&#x8EAB;&#x7684;typedef&#x5B9A;&#x4E49;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x88AB;&#x4F7F;&#x7528;&#xFF0C;&#x5F53;&#x7136;&#xFF0C;&#x6709;&#x4F8B;&#x5916;&#xFF1A;</p><ul><li><code>char</code>
</li>
<li><code>char *</code>
</li></ul>
<p>&gt;
In line with MISRA guides, unqualified character pointers are permitted, but only when they are used to point to ASCII strings. This removes the need to suppress benign compiler warnings when standard library functions that expect char * parameters are used, especially considering some compilers default unqualified char types to be signed while other compilers default unqualified char types to be unsigned.</p><p>&#x5728;&#x4E0D;&#x540C;&#x7684;&#x5206;&#x652F;&#x4E0B;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x7531;&#x5982;&#x4E0B;&#x56DB;&#x79CD;&#xFF1A;</p><ul><li><code>TickType_t</code> &#x5982;&#x679C;<code>configUSE_16_BIT_TICKS</code>&#x88AB;&#x5B9A;&#x4E49;&#x4E3A;&#x975E;&#x96F6;&#x503C;&#xFF0C;&#x5219;TickType_t&#x88AB;&#x5B9A;&#x4E49;&#x4E3A;&#x65E0;&#x7B26;&#x53F7;&#x7684;16&#x4F4D;&#x6574;&#x578B;&#x53D8;&#x91CF;&#xFF0C;&#x5426;&#x5219;&#x88AB;&#x5B9A;&#x4E49;&#x4F4D;32&#x4F4D;&#x65E0;&#x7B26;&#x53F7;&#x6574;&#x578B;&#x53D8;&#x91CF;&#x3002;&#x5BF9;&#x4E8E;32&#x4F4D;&#x7684;&#x67B6;&#x6784;&#x5E94;&#x8BE5;&#x5C06;<code>configUSE_16_BIT_TICKS</code>&#x59CB;&#x7EC8;&#x8BBE;&#x7F6E;&#x4E3A;0
</li>
<li><code>BaseType_t</code> &#x8FD9;&#x662F;&#x7528;&#x6765;&#x5B9A;&#x4E49;&#x6700;&#x9AD8;&#x6548;&#x7684;&#x3001;&#x81EA;&#x7136;&#x7684;&#x7C7B;&#x578B;&#x5BF9;&#x4E8E;&#x4E0D;&#x540C;&#x7684;&#x67B6;&#x6784;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x5BF9;&#x4E8E;32&#x4F4D;&#x7684;&#x67B6;&#x6784;&#xFF0C;<code>BaseType_t</code> &#x88AB;&#x5B9A;&#x4E49;&#x4F4D;32-bit&#x3002;&#x5982;&#x679C;<code>BaseType_t</code> &#x88AB;&#x5B9A;&#x4E49;&#x4F4D;char&#x7C7B;&#x578B;&#xFF0C;&#x6B64;&#x65F6;&#x9700;&#x8981;&#x7279;&#x522B;&#x6CE8;&#x610F;&#x4FDD;&#x8BC1;&#x5F53;signed char&#x88AB;&#x5F53;&#x4F5C;&#x8FD4;&#x56DE;&#x503C;&#x65F6;&#x503C;&#x4E3A;&#x8D1F;&#x7684;&#x65F6;&#x5019;&#x4EE3;&#x8868;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#x60C5;&#x51B5;
</li>
<li><code>UBaseType_t</code>&#x65E0;&#x7B26;&#x53F7;&#x7684;<code>BaseType_t</code> &#xFF0C;&#x6B64;&#x65F6;&#x88AB;&#x5B9A;&#x4E49;&#x4E3A;char&#x7C7B;&#x578B;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x7279;&#x522B;&#x5173;&#x6CE8;&#x4E3A;&#x8D1F;&#x7684;&#x60C5;&#x51B5;
</li>
<li><code>StackType_t</code>&#x5B9A;&#x4E49;&#x5806;&#x6808;&#x4FDD;&#x5B58;&#x6570;&#x636E;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x901A;&#x5E38;&#x60C5;&#x51B5;&#x4E0B;&#x5C31;&#x662F;&#x67B6;&#x6784;&#x7684;&#x4F4D;&#x6570;&#x3002;&#x5F53;&#x7136;&#x4E5F;&#x6709;&#x4F8B;&#x5916;&#xFF0C;&#x6BD4;&#x5982;freeRTOS&#x5185;&#x90E8;&#x4F7F;&#x7528;&#x7684;&#x5806;&#x6808;
</li></ul>
<h3 id="&#x4EE3;&#x7801;&#x5206;&#x5272;">&#x4EE3;&#x7801;&#x5206;&#x5272;</h3><ul><li>&#x7F29;&#x8FDB;&#xFF1A;&#x4F7F;&#x7528;<code>Tab</code>&#x7F29;&#x8FDB;&#xFF0C;<code>1 tab <span class="token operator">==</span> 4 spaces</code>
</li>
<li>&#x6CE8;&#x91CA;&#xFF1A;&#x6CE8;&#x91CA;&#x7684;&#x957F;&#x5EA6;&#x4E0D;&#x4F1A;&#x8D85;&#x8FC7;80&#x5217;&#xFF0C;&#x9664;&#x975E;&#x7D27;&#x63A5;&#x7740;&#x53D8;&#x91CF;&#x3001;&#x63CF;&#x8FF0;&#x3002;&#x4E0D;&#x4F7F;&#x7528;C++&#x7684;&#x53CC;&#x659C;&#x7EBF;(<code>//</code>)&#x8FDB;&#x884C;&#x6CE8;&#x91CA;&#x3002;<em>&#x8BD1;&#x8005;&#x6CE8;&#xFF1A;&#x9632;&#x6B62;&#x4EE3;&#x7801;&#x683C;&#x5F0F;&#x9519;&#x4E71;&#x5BFC;&#x81F4;&#x6E90;&#x4EE3;&#x7801;&#x88AB;&#x6CE8;&#x91CA;</em> 
</li>
<li>&#x5E03;&#x5C40;&#xFF1A;&#x76EE;&#x7684;&#x662F;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x65B9;&#x4FBF;&#x4E66;&#x5199;&#x4E0E;&#x9605;&#x8BFB;&#xFF0C;&#x4EE5;&#x4E0B;&#x662F;&#x7B80;&#x5355;&#x7684;&#x793A;&#x4F8B;&#xFF1A;
</li></ul>
<h4 id="&#x6587;&#x4EF6;&#x5E03;&#x5C40;">&#x6587;&#x4EF6;&#x5E03;&#x5C40;</h4><pre><code>/* &#x9996;&#x5148;&#x662F;&#x5E93;&#x6587;&#x4EF6;<span class="token punctuation">..</span> */
<span class="token comment" spellcheck="true">#include &lt;stdlib.h&gt;</span>

/* <span class="token punctuation">..</span>.&#x7D27;&#x63A5;&#x7740;&#x662F;freeRTOS&#x81EA;&#x8EAB;&#x7684;&#x5934;&#x6587;&#x4EF6;&#x5305;&#x542B;<span class="token punctuation">..</span>. */
<span class="token comment" spellcheck="true">#include &quot;FreeRTOS.h&quot;</span>

/* <span class="token punctuation">..</span>.&#x5176;&#x4ED6;&#x5934;&#x6587;&#x4EF6;. */
<span class="token comment" spellcheck="true">#include &quot;HardwareSpecifics.h&quot;</span>

/* <span class="token comment" spellcheck="true">#defines &#x5B8F;&#x5B9A;&#x4E49;&#xFF0C;&#x5C3D;&#x53EF;&#x80FD;&#x7684;&#x4F7F;&#x7528;&#x62EC;&#x53F7;&#xFF0C;&#x9632;&#x6B62;&#x8FB9;&#x754C;&#x6548;&#x5E94;. */</span>
<span class="token comment" spellcheck="true">#define A_DEFINITION    ( 1 )</span>

/*
 * static&#x9650;&#x5B9A;&#x7684;&#x6587;&#x4EF6;&#x4F5C;&#x7528;&#x57DF;&#x51FD;&#x6570;&#xFF0C;&#x8FD9;&#x90E8;&#x5206;&#x7684;&#x6CE8;&#x91CA;&#x98CE;&#x683C;&#x662F;&#x6BCF;&#x884C;
 * &#x90FD;&#x662F;&#x4EE5;&#x2018;*&#x2019;&#x5F00;&#x5934;.
 */
static void prvAFunction<span class="token punctuation">(</span> uint32_t ulParameter <span class="token punctuation">)</span><span class="token punctuation">;</span>

/* &#x6587;&#x4EF6;&#x4F5C;&#x7528;&#x57DF;&#x53D8;&#x91CF;&#xFF0C;&#x6CE8;&#x91CA;&#x98CE;&#x683C;&#x4E0E;&#x6587;&#x4EF6;&#x4F5C;&#x7528;&#x57DF;&#x51FD;&#x6570;&#x4E0D;&#x540C;&#xFF0C;&#x6BCF;&#x884C;
&#x4E0D;&#x5728;&#x4EE5;&#x2018;*&#x2019;&#x5F00;&#x5934;*/
static BaseType_t xMyVariable.

/* &#x4E0B;&#x9762;&#x7684;&#x8FD9;&#x4E2A;&#x5206;&#x5272;&#x884C;&#x5E94;&#x7528;&#x4E8E;&#x6240;&#x6709;&#x7684;&#x51FD;&#x6570;&#x4E4B;&#x540E;&#xFF0C;&#x540C;&#x65F6;&#x7D27;&#x63A5;&#x7740;&#x4E00;&#x4E2A;&#x7A7A;&#x767D;&#x884C;&#xFF0C;&#x7136;&#x540E;
&#x624D;&#x662F;&#x4E0B;&#x4E00;&#x4E2A;&#x51FD;&#x6570; */

/*-----------------------------------------------------------*/

void vAFunction<span class="token punctuation">(</span> void <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    /* &#x51FD;&#x6570;&#x5B9A;&#x4E49;&#x653E;&#x5728;&#x8FD9;&#xFF0C;&#x6CE8;&#x610F;&#x5C06;&#x82B1;&#x62EC;&#x53F7;&#x95ED;&#x5408; */
<span class="token punctuation">}</span>
/*-----------------------------------------------------------*/

static UBaseType_t prvNextFunction<span class="token punctuation">(</span> void <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    /* &#x51FD;&#x6570;&#x5B9A;&#x4E49;. */
<span class="token punctuation">}</span>
/*-----------------------------------------------------------*/</code></pre>
<h4 id="c&#x6587;&#x4EF6;&#x683C;&#x5F0F;">C&#x6587;&#x4EF6;&#x683C;&#x5F0F;</h4><pre><code>/* &#x51FD;&#x6570;&#x540D;&#x79F0;&#x603B;&#x662F;&#x5199;&#x5728;&#x4E00;&#x884C;&#xFF0C;&#x5305;&#x62EC;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B;&#x3002; &#x5DE6;&#x62EC;&#x53F7;&#x4E4B;&#x524D;&#x6CA1;&#x6709;&#x7A7A;&#x683C;&#xFF0C;&#x5DE6;&#x62EC;&#x53F7;&#x4E4B;&#x540E;
&#x6709;&#x7A7A;&#x683C;&#xFF0C;&#x6BCF;&#x4E2A;&#x9017;&#x53F7;&#x540E;&#x6709;&#x7A7A;&#x683C;&#x3002;&#x53C2;&#x6570;&#x5FC5;&#x987B;&#x8BE6;&#x5C3D;&#x7ED9;&#x51FA;&#xFF0C;&#x63CF;&#x8FF0;&#x6027;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x81EA;&#x89E3;&#x91CA;&#x3002;&#x5982;&#x679C;&#x62EC;&#x53F7;
&#x4E0D;&#x5728;&#x540C;&#x4E00;&#x884C;&#xFF0C;&#x6BCF;&#x884C;&#x6392;&#x5F00;&#xFF0C;&#x5217;&#x5BF9;&#x9F50;*/
void vAnExampleFunction<span class="token punctuation">(</span> long lParameter1, unsigned short usParameter2 <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
/* &#x53D8;&#x91CF;&#x58F0;&#x660E;&#x4E0D;&#x9700;&#x8981;&#x7F29;&#x8FDB; */
uint8_t ucByte<span class="token punctuation">;</span>

    /* &#x4EE3;&#x7801;&#x7F29;&#x8FDB;&#xFF0C;&#x82B1;&#x62EC;&#x53F7;&#x72EC;&#x5360;&#x4E00;&#x884C;&#xFF0C;&#x5217;&#x5BF9;&#x9F50;*/
    for<span class="token punctuation">(</span> ucByte <span class="token operator">=</span> 0U<span class="token punctuation">;</span> ucByte <span class="token operator">&lt;</span> fileBUFFER_LENGTH<span class="token punctuation">;</span> ucByte++ <span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        /* &#x518D;&#x6B21;&#x7F29;&#x8FDB;. */
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

/* <span class="token keyword">for</span> <span class="token keyword">while</span> <span class="token keyword">do</span> &#x548C; if&#x8BED;&#x53E5;&#x6709;&#x76F8;&#x540C;&#x7684;&#x6A21;&#x5F0F;&#xFF0C;&#x5DE6;&#x62EC;&#x53F7;&#x540E;&#x6709;&#x7A7A;&#x683C;&#xFF0C;&#x53F3;&#x62EC;&#x53F7;&#x524D;&#x6709;&#x7A7A;&#x9694;&#xFF0C;
&#x6BCF;&#x4E2A;&#x5206;&#x53F7;&#x540E;&#x6709;&#x7A7A;&#x683C;&#xFF0C;&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x4F18;&#x5148;&#x7EA7;&#x663E;&#x5F0F;&#x8868;&#x73B0;&#x51FA;&#x6765;&#xFF0C;&#x4E0D;&#x8981;&#x4F9D;&#x8D56;&#x9ED8;&#x8BA4;&#x4F18;&#x5148;&#x7EA7;*/
for<span class="token punctuation">(</span> ucByte <span class="token operator">=</span> 0U<span class="token punctuation">;</span> ucByte <span class="token operator">&lt;</span> fileBUFFER_LENGTH<span class="token punctuation">;</span> ucByte++ <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
<span class="token punctuation">}</span>

while<span class="token punctuation">(</span> ucByte <span class="token operator">&lt;</span> fileBUFFER_LENGTH <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
<span class="token punctuation">}</span>

/* &#x4E0D;&#x8981;&#x4F9D;&#x9760;&#x64CD;&#x4F5C;&#x7B26;&#x4F18;&#x5148;&#x7EA7;&#xFF0C;&#x6BCF;&#x4E2A;&#x6761;&#x4EF6;&#x7528;&#x62EC;&#x53F7;&#x5305;&#x542B; */
if<span class="token punctuation">(</span> <span class="token punctuation">(</span> ucByte <span class="token operator">&lt;</span> fileBUFFER_LENGTH <span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span> ucByte <span class="token operator">!=</span> 0U <span class="token punctuation">)</span> <span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    /* &#x4E0D;&#x4F9D;&#x8D56;&#x64CD;&#x4F5C;&#x7B26;&#x4F18;&#x5148;&#x7EA7;&#x7684;&#x4F8B;&#x5B50; */
    ulResult <span class="token operator">=</span> <span class="token punctuation">(</span> <span class="token punctuation">(</span> ulValue1 + ulValue2 <span class="token punctuation">)</span> - ulValue3 <span class="token punctuation">)</span> * ulValue4<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

/* &#x6761;&#x4EF6;&#x7F16;&#x8BD1;&#x5217;&#x51FA;&#x6765;&#xFF0C;&#x5E76;&#x6309;&#x7167;&#x4EE3;&#x7801;&#x7F29;&#x8FDB;&#x98CE;&#x683C;*/
<span class="token comment" spellcheck="true">#if( configUSE_TRACE_FACILITY == 1 )</span>
<span class="token punctuation">{</span>
    /* &#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x8DDF;&#x8E2A;&#x7684;&#x8BA1;&#x6570;&#x5668;&#x5230;TCB. */
    pxNewTCB-<span class="token operator">&gt;</span>uxTCBNumber <span class="token operator">=</span> uxTaskNumber<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment" spellcheck="true">#endif</span>

/*&#x5DE6;&#x65B9;&#x62EC;&#x53F7;&#x540E;&#x7A7A;&#x683C;&#xFF0C;&#x53F3;&#x65B9;&#x62EC;&#x53F7;&#x524D;&#x7A7A;&#x683C;*/
ucBuffer<span class="token punctuation">[</span> 0 <span class="token punctuation">]</span> <span class="token operator">=</span> 0U<span class="token punctuation">;</span>
ucBuffer<span class="token punctuation">[</span> fileBUFFER_LENGTH - 1U <span class="token punctuation">]</span> <span class="token operator">=</span> 0U<span class="token punctuation">;</span></code></pre>

                                
                                </section>
                            
                        </div>
                    </div>
                
            </div>

            
                
                <a href="freeRTOS介绍.html" class="navigation navigation-prev " aria-label="Previous page: 简介">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="许可.html" class="navigation navigation-next " aria-label="Next page: 许可">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"编码规则和风格","level":"1.2.1","depth":2,"next":{"title":"许可","level":"1.2.2","depth":2,"path":"简介/许可.md","ref":"简介/许可.md","articles":[]},"previous":{"title":"简介","level":"1.2","depth":1,"path":"简介/freeRTOS介绍.md","ref":"简介/freeRTOS介绍.md","articles":[{"title":"编码规则和风格","level":"1.2.1","depth":2,"path":"简介/编码规则和风格.md","ref":"简介/编码规则和风格.md","articles":[]},{"title":"许可","level":"1.2.2","depth":2,"path":"简介/许可.md","ref":"简介/许可.md","articles":[]},{"title":"快速开始指南","level":"1.2.3","depth":2,"path":"简介/快速开始指南.md","ref":"简介/快速开始指南.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["prismx","-highlight","-search","duoshuo","ga","theme-comscore"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"ga":{"configuration":"auto","token":"UA-80700049-1"},"duoshuo":{"short_name":"tangguocheng","theme":"default"},"prismx":{"css":["prismjs/themes/prism-tomorrow.css"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-comscore":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"mobi":{"fontSize":12,"footerTemplate":null,"headerTemplate":null,"margin":{"bottom":36,"left":62,"right":62,"top":36},"pageNumbers":false,"paperSize":"a4"},"theme":"default","author":"tangguocheng","pdf":{"pageBreaksBefore":"/","headerTemplate":null,"paperSize":"a4","margin":{"right":62,"left":62,"top":36,"bottom":36},"fontSize":12,"fontFamily":"Arial","footerTemplate":null,"chapterMark":"pagebreak","pageNumbers":false},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"freeRTOS中文文档","language":"Chinese","links":{"sidebar":{"博客":"http://www.xn--4gqa63c686ta68iba.ren/"}},"gitbook":"*","description":"freeRTOS中文文档","extension":null},"file":{"path":"简介/编码规则和风格.md","mtime":"2016-08-29T02:09:49.224Z","type":"markdown"},"gitbook":{"version":"3.2.0","time":"2016-09-18T09:07:11.640Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-duoshuo/duoshuo.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-ga/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

